// pages/redactEvent/redactEvent.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    eid:0,
    type_id:0,
    type_name:'',
    start_time:'',
    dur_time:'',
    descript:'',
    imgSrc:''
  },
  previewImage: function (e) {
    var that = this,
      //获取当前图片的下表
      index = e.currentTarget.dataset.index,
      //数据源
      imgSrc = this.data.imgSrc;
    wx.previewImage({
      //当前显示下表
      current: imgSrc[index],
      //数据源
      urls: imgSrc
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var eid = options.id;
    that.setData({
      eid: eid
    });
   
  },

  update:function (e) {
    wx.navigateTo({
      url: '../updateEvent/updateEvent?id='+this.data.eid,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    var eid = that.data.eid;
    wx.request({
      url: app.d.ceshiUrl + '/Api/Event/detail',
      method: "post",
      data: {
        eid: eid,
      },
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res)
        if (res.data.status == 1) {
          that.setData({
            info: res.data.info,
            type_name: res.data.info.type_name,
            start_time: res.data.info.start_time,
            dur_time: res.data.info.dur_time,
            descript: res.data.info.descript,
            imgSrc: res.data.imgSrc
          });
        } else {
          wx.showToast({
            title: res.data.err,
          })
        }
      },
      fail: function (e) {
        wx.showToast({
          title: '网络异常！',
          duration: 30000
        });
      },
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})